//
// Created by tang on 23-3-11.
//

#ifndef HEFENGWEATHERPLUGIN_HPP
#define HEFENGWEATHERPLUGIN_HPP

#include <plugin/plugin_interface.hpp>
#include <service/cfg_service.hpp>
#include <service/http_service.hpp>
#include <utils/safe_value.hpp>
#include "content/view_base.hpp"
#include "core/timespan.hpp"
#include "hefeng_weather_data.hpp"

class HefengWeatherPlugin final : public IPlugin
{
public:
    HefengWeatherPlugin ();
    ~HefengWeatherPlugin ();

    const PluginInfo   *get_plugin_info () const override;
    bool                initialize () override;
    void                tick (pi_time_t delta, pi_time_t total) override;
    void                cleanup () override;
    const char*         name () const override;
    const ImageContent *icon () const override;
    ui_view            *content () const override;

private:
    IHttpService   *httpService_;
    IConfigService *cfgService_;

    ImageContent *icon_;

    safe_value<std::string> *api_key_;
    safe_value<int>         *update_interval_;
    std::string             *city_id_;

    ui_view    *main_view_;
    HefengData *data_;

    pi_time_t   last_update_;
};

#endif /* HEFENGWEATHERPLUGIN_HPP */
